<?
	chdir("..");
	if( $_POST['change'] ){
		$a_string = array( 'siteurl','sitename','adminemail','adlogin','adpassword','dbServer','dbUser','dbPass','dbName' );
		$str = "<?\n";
		while ($a = each($_POST)){
			if (in_array($a[0], $a_string)){
				$str .= '$'."{$a[0]} = \"".preg_replace("/[\"\\\\]/", "\\\\\\0", $a[1])."\";\n";
			}
		}
		$str .= "\n?>";
		$f = fopen("config.php", "w");
		if ($f){
			fwrite($f, $str);
			fclose($f);
#			echo "<div style='color: red;'>Update variables successful.</div><br>";
		}else{
#			echo "<div style='color: red;'>Update variables failed. Check write permissions for file \"config.php\".</div><br>";
		}
	}
	ob_start();

	include("config.php");
	include("siteadmin/accesscontrol.php");

	include("siteadmin/header.php");
?>
<p><font face=arial size=3>
	<P><b>
		To update your settings, simply change them using the form below and then click on the
		"Update Settings &gt;&gt;" button at the bottom of the page.
	</B> 
	<form method="POST">
	<input type="hidden" name="action" value="config">
	<TABLE class=design bgColor=#ffffff cellPadding=3 cellSpacing=0 width=100% border='1' BORDERCOLOR="#C0C0C0" STYLE="border-collapse: collapse">
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			Site Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Site Name:</TD>
		<TD width=60% class='a1'><input size=55 name="sitename" value="<?=$sitename?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Site URL:</TD>
		<TD width=60% class='a1'><input size=55 name="siteurl" value="<?=$siteurl?>"></TD>
	</TR>
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			Admin Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Email:</TD>
		<TD width=60% class='a1'><input size=55 name="adminemail" value="<?=$adminemail?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">User Name:</TD>
		<TD width=60% class='a1'><input size=55 name="adlogin" value="<?=$adlogin?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Password:</TD>
		<TD width=60% class='a1'><input size=55 name="adpassword" value="<?=$adpassword?>"></TD>
	</TR>
	<TR>
		<TD class='a1' colspan=2 align=left><b>
			MySQL Database Details
		</b></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Server:</TD>
		<TD width=60% class='a1'><input size=55 name="dbServer" value="<?=$dbServer?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">User:</TD>
		<TD width=60% class='a1'><input size=55 name="dbUser" value="<?=$dbUser?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Password:</TD>
		<TD width=60% class='a1'><input size=55 name="dbPass" value="<?=$dbPass?>"></TD>
	</TR>
	<TR>
		<TD class='a1' style="padding-left:20px">Database Name:</TD>
		<TD width=60% class='a1'><input size=55 name="dbName" value="<?=$dbName?>"></TD>
	</TR>
	<TR>
		<TD class='a1' colspan=2 align=right>
			<input type="submit" name=change value="Update Settings &gt;&gt;">
		</TD>
	</TR>
	</table>
	</form>
	<br><br><br>
</p>
<?
	include("siteadmin/footer.php");
?>